<template>
	<view class="u-padding-20">
		<!-- <view style="color:#0c838b;" class="u-padding-bottom-20"></view> -->
		<view class="price_con">
			<text class="va_m">标题</text>
			<input v-model="title" style="right:20rpx;" class="va_m dis_inl_blo" type="text" placeholder="请输入公告标题">
		</view>
		<view style="overflow: hidden !important;border:1rpx solid #ddd;">
			<cu-editor ref="editor" url="https://admin.gslhzhwy.com/api/upload/file" :header="header" :formData="formData" :content="content" @before="onUploadBefore" @update="onUpdate" @save="onSave"></cu-editor>
		</view>
		<button class="u-margin-bottom-80 btn_con" @click="releaseNotice">确定发布</button>
		<!-- 弹框提示 -->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import cuEditor from '@/components/cu-editor/cu-editor'
	import { handleHtmlImage } from '@/components/cu-editor/util'
	import {
		releaseNotice
	} from "@/service/indexService.js";
	export default {
		components: {
		  cuEditor
		},
		data () {
			return {
				id:0,
				title:'',
				
				content: '',
				uploadUrl: 'https://admin.gslhzhwy.com/api/upload/file',
				header: {},
				formData: {}
			}
		},
		onLoad(options) {
			this.id=options.id
		},
		methods:{
			onUploadBefore: function() {
				this.formData = {
					timestamp: (Date.parse(new Date())) / 1000
				}
			},
			onUpdate(res) {
				
			},
			//保存
			onSave(e) {
				let html = e.html
				html = handleHtmlImage(html)
				this.content=e.html
			
			},
			
			releaseNotice:function(){
				releaseNotice({
					type: 2,
					title:this.title,
					content:this.content
				}).then(res=>{
					if(res.code==200){
						this.$refs.uToast.show({
							type: 'success',
							title: '发布成功！',
							icon:false
						})
						setTimeout(function(){
							uni.navigateBack()
						},2000)
					}else{
						this.$refs.uToast.show({
							type: 'error',
							title: res.msg,
							icon:false
						})
					}
					
				})
			}
		}
	}
</script>

<style lang="scss">
	.price_con{
		height:70rpx;
		line-height: 70rpx;
		margin-bottom: 20rpx;
		border-bottom:1rpx solid #ddd;
	}
	.price_con input{
		width:80%;
		padding:0 10rpx;
		text-align: left;
		border-radius: 10rpx;
		font-size: 26rpx;
		margin-left:20rpx;
		// border:1rpx solid #ddd;
	}
	.price_intro textarea{
		width:93%;
		height:200rpx;
		padding:20rpx;
		border-radius: 10rpx;
		font-size: 26rpx;
		// border:1rpx solid #ddd;
	}
	.fixed-top.isFixed.data-v-7b039d96{
		position: static !important;
		// top:115rpx !important;
		// width:93% !important;
	}
	scroll-view.data-v-7b039d96{
		height:600rpx !important;
	}
	.fixed-bottom.data-v-7b039d96{
		display: block !important;
		position: static !important;
	}
	.btn_con{
		height:70rpx;
		line-height: 70rpx;
		font-size: 30rpx;
		border-radius: 35rpx;
		background-image: url('https://resourse.cnlhjt.com/upload/20220825/d1aa35c1d129137d9b12c8f34e59c5bc.png');
		background-size: 100% 70rpx;
		color:#fff;
		margin-top:130rpx;
	}
</style>
